<?php


namespace App\Admin\Controllers\Export;

use App\Exports\DailyExport;
use App\Exports\TurnoverExport;
use Carbon\Carbon;
use Encore\Admin\Layout\Content;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Maatwebsite\Excel\Facades\Excel;
/**
 * Created By FreeAbrams
 * Date: 2020/11/26
 */
class DailyExportController extends Controller
{
	public function index(Content $content)
	{
		return $content->header('日结报表导出')
	        ->title('日结报表导出')
			->row(view('admin.export.datetime-select', [
				'route' => route('dailyExport'),
				'routeIndex' => route('dailyExport.index')
			]));
	}
	
	public function export(Request $request)
	{
		$timeBetween = $this->requestReturnTimeBetween($request);
		if(empty($timeBetween)) {
			return false;
		}
		
		return Excel::download(new DailyExport($timeBetween), '日结.xls');
	}
}